package com.atguigu.spzx.common.util;

import com.atguigu.spzx.model.entity.sys.SysUser;
import com.atguigu.spzx.model.entity.user.UserInfo;

//共享登录身份数据的工具类
public class AuthUtil {
    private static ThreadLocal<SysUser> SYSUSER_THREAD_LOCAL = new ThreadLocal<>();

    public static void set(SysUser sysUser){
        SYSUSER_THREAD_LOCAL.set(sysUser);
    }
    public static SysUser get(){
        return SYSUSER_THREAD_LOCAL.get();
    }
    public static void remove(){
        SYSUSER_THREAD_LOCAL.remove();
    }

    private static ThreadLocal<UserInfo> USER_INFO_THREAD_LOCAL = new ThreadLocal<>();

    public static void setUserInfo(UserInfo userInfo){
        USER_INFO_THREAD_LOCAL.set(userInfo);
    }
    public static UserInfo getUserInfo(){
        return USER_INFO_THREAD_LOCAL.get();
    }
    public static void removeUserInfo(){
        USER_INFO_THREAD_LOCAL.remove();
    }
}
